<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:p="http://primefaces.prime.com.tr/ui">

<ui:composition template="_patrimonio.xhtml">
	<ui:define name="corpo">

		<div id="conteudo">

			<h:form id="form">

				<h2>
					<h:outputText value="STATUS PATRIMÔNIO"/>
				</h2>
				<hr />

				<p:messages id="msg" />
				
				<div align="center">
				<p:fieldset legend="Pesquisar">
								
				<h:outputLink value="javascript:void(0)" onclick="dlgPatrimonio.show();">
					<h:outputLabel value="Pesquisar" rendered="#{empty patrimonioBean.patrimonio.id}"/>
					<h:outputLabel value="Tombo Patrimonial: " rendered="#{not empty patrimonioBean.patrimonio.id}"/>
				</h:outputLink>
				
				<h:outputLink value="javascript:void(0)" onclick="dlgPatrimonio.show();">
				<h:graphicImage value="resources/img/lupa3.png" style="width: 40px;" onclick="dlgPatrimonio.show();" rendered="#{empty patrimonioBean.patrimonio.id}" />
					<h:outputText id="pat" value="#{patrimonioBean.patrimonio.tombo}" onclick="dlgPatrimonio.show();" style="text-align: center; float: center; font-weight:bold;" rendered="#{not empty patrimonioBean.patrimonio.id}" />
				</h:outputLink>
				
				</p:fieldset>
				</div>
				
				<p:fieldset >
				
				<h:outputLabel value="Tombo: " for="tombo" style="color: #87CEFA; font-weight:bold;" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
				<p:inputText id="tombo" value="#{patrimonioBean.patrimonio.tombo}" disabled="true" /><br /><br />
				
				<h:outputLabel value="Descrição: " for="descricao" style="color: #87CEFA; font-weight:bold;" />
				<p:inputText id="descricao" value="#{patrimonioBean.patrimonio.item.material.nome}" disabled="true" style="width: 400px;" /><br /><br />
											
				<h:outputLabel value="Status: " for="status" style="color: #87CEFA; font-weight:bold;" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
				<h:selectOneMenu id="status" value="#{patrimonioBean.patrimonio.status}">
					<f:selectItem itemLabel="" noSelectionOption="true" ></f:selectItem>
					<f:selectItem itemLabel="Em Uso" itemValue="Em Uso" />
					<f:selectItem itemLabel="Emprestado" itemValue="Emprestado" />
					<f:selectItem itemLabel="Inservível" itemValue="Inservível" />
				</h:selectOneMenu><br /><br />
				
				<h:outputLabel value="Localização: " for="local3" style="color: #87CEFA; font-weight:bold;" rendered="#{empty patrimonioBean.patrimonio.id}" />
				<p:inputText id="local3" value="#{patrimonioBean.patrimonio.setor.nome}" rendered="#{empty patrimonioBean.patrimonio.id}" disabled="true" style="width: 250px;" />
				
				<h:outputLink value="javascript:void(0)" onclick="dlgSetor.show();" rendered="#{not empty patrimonioBean.patrimonio.id}">
					<h:outputLabel value="Localização: " for="local" style="color: #87CEFA; font-weight:bold;" />
					<p:inputText id="local" value="#{patrimonioBean.patrimonio.setor.nome}" style="width:250px;" />&nbsp;&nbsp;
				</h:outputLink>	
				
				<h:outputLabel value="Bloco: " for="local2" style="color: #87CEFA; font-weight:bold;" />
				<p:inputText id="local2" value="#{patrimonioBean.patrimonio.setor.bloco.sigla}" disabled="true" style="width: 250px;" /><br /><br />
				
				<h:outputLabel value="Observação: " for="obs" style="color: #87CEFA; font-weight:bold;" />
				<h:outputText id="obs" value="#{patrimonioBean.patrimonio.obs}" disabled="true" />
				<br /><br />

				<p:commandButton id="grava" value="GRAVAR" action="#{patrimonioBean.grava}" ajax="false" image="ui-icon-disk" rendered="#{not empty patrimonioBean.patrimonio.id}">
					<f:ajax render="@all" />
				</p:commandButton>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;	
				
				<p:commandButton id="cancel" value="CANCELAR EDIÇÃO" action="formAlterPatrimonio.xhtml"
						rendered="#{not empty patrimonioBean.patrimonio.id}" ajax="false" icon="ui-icon-arrowreturnthick-1-w">
						<f:ajax render="@all" />
					</p:commandButton>
				<p />
				
				</p:fieldset>						

			</h:form>
			
			<p:dialog header="Patrimônio Cadastrado" widgetVar="dlgPatrimonio" model="true" width="700" showEffect="hide">
					<h:form id="form1">

						<p:outputPanel id="pats">
							<p:dataTable value="#{patrimonioBean.patrimonios}" var="patrimonio" paginator="true"
								rows="10" emptyMessage="Não Encontrado">

								<p:column filterBy="#{patrimonio.tombo}" filterMatchMode="contains"
									headerText="Tombo">
									<h:commandLink value="#{patrimonio.tombo}" id="patrimonio" onclick="dlgPatrimonio.hide()">
										<f:setPropertyActionListener target="#{patrimonioBean.patrimonio}" value="#{patrimonio}" />
									</h:commandLink>
								</p:column>
								
								<p:column headerText="Descrição">
									<h:outputText value="#{patrimonio.item.material.nome}" />
								</p:column>
									
							</p:dataTable>
						</p:outputPanel>

					</h:form>
				</p:dialog>
				
			<p:dialog header="Setores" widgetVar="dlgSetor" model="true"
				width="500" showEffect="hide">
				<h:form id="form2">

					<p:outputPanel id="setores">

						<p:dataTable id="listSetor" value="#{setorBean2.setores}"
							paginator="true" rows="8" var="setor"
							style="font-size: 11px" emptyMessage="Não Encontrado">


							<f:facet name="header">
								<h:outputText value="SETORES CADASTRADOS" />
							</f:facet>

							<p:column filterBy="#{setor.nome}" filterMatchMode="contains"
									headerText="Nome">
									<h:commandLink value="#{setor.nome}" onclick="dlgSetor.hide()"
										id="setor">
										<f:setPropertyActionListener
											target="#{patrimonioBean.patrimonio.setor}" value="#{setor}" />
									</h:commandLink>
								</p:column>

							<p:column sortBy="#{setor.bloco.sigla}"
								filterBy="#{setor.bloco.sigla}" filterMatchMode="contains"
								headerText="Bloco">
								<h:outputText value="#{setor.bloco.sigla}" />
							</p:column>

						</p:dataTable>

					</p:outputPanel>
				</h:form>
			</p:dialog>	
				
		</div>


	</ui:define>
</ui:composition>
</html>